<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码 - 快递代拿系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <link rel="stylesheet" href="../../../assets/css/bootstrap.css"/>
    <link rel="stylesheet" href="../../../assets/css/bootstrap-table.css"/>
    <link rel="stylesheet" href="../../../assets/css/express.css">
</head>
<body>
<div class="container-fluid">
    <!-- 顶栏 -->
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand">快递代拿管理系统</a>
            </div>
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <div id="showUser"><span class="caret"></span></div>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="/logout">注销</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
    <!-- 主体 -->
    <div class="row">
        <!-- 左侧菜单 -->
        <div class="col-md-2">
            <ul class="nav nav-pills nav-stacked" id="nav">
                <li><a href="/staff/home">接单大厅<span class="glyphicon glyphicon-home pull-right"/></a></li>
                <li><a href="/staff/express">我的订单<span class="glyphicon glyphicon-user pull-right"/></a></li>
                <li class="active"><a href="/staff/password">修改密码<sapn class="glyphicon glyphicon-pencil pull-right" /></a></li>
                <li><a href="/logout">退出系统<sapn class="glyphicon glyphicon-log-out pull-right" /></a></li>
            </ul>
        </div>
        <!-- 右侧数据 -->
        <div class="panel col-md-8">
            <form class="form-horizontal" id="passwordForm">
                <div class="form-group">
                    <label for="inputOldPassword" class="col-sm-2 control-label">原始密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" id="inputOldPassword" name="oldPassword">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputNewPassword" class="col-sm-2 control-label">新密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" id="inputNewPassword" name="newPassword">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputNewPassword1" class="col-sm-2 control-label">重复新密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" id="inputNewPassword1" name="newPassword1">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary">重置密码</button>
                        <button type="reset" class="btn btn-default">重新输入</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="../../../assets/js/jquery3.3.1.min.js"></script>
<script src="../../../assets/js/jquery.validate.min.js"></script>
<script src="../../../assets/js/bootstrap.min.js"></script>
<script src="../../../assets/js/bootstrap-table.min.js"></script>
<script src="../../../assets/js/bootstrap-table-zh-CN.min.js"></script>
<script src="../../../assets/layer/layer.js"></script>
<script src="../../../assets/js/http.js"></script>
<script type="text/javascript">
    $().ready(function() {
        $("#passwordForm").validate({
            rules: {
                oldPassword: "required",
                newPassword: {
                    required: true,
                    minlength: 5
                },
                newPassword1: {
                    required: true,
                    minlength: 5,
                    equalTo: "#inputNewPassword"
                }
            },
            messages: {
                oldPassword: "原始密码不能为空",
                newPassword: {
                    required: "新密码不能为空",
                    minlength: "密码长度不能小于 5 个字母"
                },
                newPassword1: {
                    required: "新密码不能为空",
                    minlength: "密码长度不能小于 5 个字母",
                    equalTo: "两次密码输入不一致"
                }
            },
            submitHandler: function () {
                var op = $("#inputOldPassword").val();
                var np = $("#inputNewPassword").val();
                sendJson("post", "/password", {"oldPassword":op,"newPassword":np}, false, function (res) {
                    if (!res.status) {
                        layer.msg(res.info,{icon:2});
                    } else {
                        $.message({message: "修改成功，即将退出登录", type: 'success'});
                        setTimeout("new function(){window.location.href='/logout'}","3000");
                    }
                }, function () {
                    layer.msg("未知错误",{icon:2});
                });
            }
        });
    });
</script>
</body>
</html>